using System;
using System.IO;
using System.Text;
using System.Net;

namespace Conusic
{
    public sealed class WebResponseCp1251Reader
    {
        public WebResponse response { get; private set; }

        public WebResponseCp1251Reader(WebResponse response)
        {
            this.response = response;
        }

        public string ReadToEndAndCloseAll()
        {
            var responseStream = response.GetResponseStream();
            var reader = new StreamReader(responseStream, Encoding.GetEncoding(1251));

            string page = reader.ReadToEnd();

            reader.Close();
            response.Close();
            responseStream.Close();
            return page;
        }
    }
}